<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script>
        class Animal {
            constructor(age, weight) {
                this.age = age;
                this.weight = weight;
            }
            breathe() {
                console.log('呼吸')
            }
            // 定义静态方法
            static isAnimal(obj) {
                return obj instanceof Animal
            }
        }
        // var a1 = new Animal(5, 10);
        // console.log(a1);
        // a1.breathe();
        // Animal.eat();
        class Pig extends Animal {
            constructor(age, weight, name, color) {
                super(age, weight);
                this.name = name;
                this.color = color;
            }
            dig() {
                console.log('拱白菜')
            }
        }
        var p1 = new Pig(2, 100, '佩奇', 'white');
        console.log(p1);
        p1.dig();
        p1.breathe();
        console.log(Pig.isAnimal(p1));
    </script>
</head>

<body>

</body>

</html>